﻿using System;
using System.Runtime.InteropServices;
using System.IO;

namespace WindowsFormsApplication1
{
    class Symlink
    {
        [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
        static extern bool CreateSymbolicLink(string lpSymlinkFileName, string lpTargetFileName, int dwFlags);

        static int SYMLINK_FLAG_DIRECTORY = 0x1;

        public static bool linkFile(string source, string target)
        {
            if (CreateSymbolicLink(source, target, 0x0))
            {
                return true;
            }
            return false;
        }

        public static bool linkFolder(string source, string target)
        {
            if (CreateSymbolicLink(source, target, SYMLINK_FLAG_DIRECTORY))
            {
                return true;
            }
            return false;
        }
    }
}
